<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />

    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>-->
    <!--<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>-->
    <!--<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>-->
    <!--[endif]-->
    <script type="text/javascript" src="../../common/js/public.js"></script>
    <script type="text/javascript" src="../../common/js/publicUtils.js"></script>
    <style>
        .menudiv .layui-input-inline,.buttondiv .layui-input-inline {
            float: left;
            width: 450px !important;
            margin-right: 10px;
        }
        .buttondiv{
            display: none;
        }
        .layui-form-item{
            width: 700px;
        }
        .error{
            color: red;
            line-height: 20px;
        }

        input.error, select.error {
            background-color: #fbe2e2;
            border-color: #c66161;
            color: #c00;
        }

    </style>
</head>
<body>
<div class="layui-fluid" id="flowDiv" onload="onLoad()">
    <div class="zTreeBackground right" style="float: left;width:65%; padding-left:0%;margin-top: 3%">
        <div class="menudiv">
            <form class="layui-form"  id="menuform" >

                <div class="layui-form-item">
                    <label class="layui-form-label">类&emsp;&emsp;型</label>
                    <div class="layui-input-inline">
                        <input type="text" id="typeName"   autocomplete="off" disabled="disabled" class="layui-input">
                        <input type="hidden" id="type" name="type">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">所属关系</label>
                    <div class="layui-input-inline">
                        <input type="text"  id="pName"  autocomplete="off" disabled="disabled"  class="layui-input">
                        <input type="hidden" id="pid" name="pid">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red;">*</span>名&emsp;&emsp;称</label>
                    <div class="layui-input-inline">
                        <input type="text" id="name" name="name" autocomplete="off" placeholder="请输入名称" class="layui-input">
                    </div>
                </div>



                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red;">*</span>IFD&ensp;编码</label>
                    <div class="layui-input-inline">
                        <input type="text" id="fid" name="fid" autocomplete="off" placeholder="请输入IFD编码" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label"><span style="color: red;">*</span>排&emsp;&emsp;序</label>
                        <div class="layui-input-inline">
                            <input type="text" id="sort" name="sort" id="sort"   placeholder="请输入排序" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">备&emsp;&emsp;注</label>
                        <div class="layui-input-inline">
                            <textarea id="comment" name="comment" placeholder="请输入备注" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<SCRIPT type="text/javascript">

    var form;

    $(function () {
        var type=getUrlParam('type');
        var pid=getUrlParam('pid');
        var pName=getUrlParam('pName');
        init(type,pid,pName)
    });

    //初始化表单数据
    function init(type,pid,pName){
        if(type==1){
            $("#typeName").val("领域类型");
        }else if(type==2){
            $("#typeName").val("专业类型");
        }
        $("#type").val(type);
        $("#pName").val(pName);
        $("#pid").val(pid);
    }

    layui.use(['form', 'layer'], function() {
        form = layui.form
            , layer = layui.layer;

    })

    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURIComponent(r[2]);
        return null;
    }

    /**
     * 保存菜单
     */
    function submit(index, layero,type){
        if($(validform().form())[0]){
            var menuflag = $(".menudiv").css("display");
            var formData = new FormData($("#menuform")[0]);
            var result;
            publicAjaxFormData (null,'infDisciplines/insertInfDisciplines',formData,false,null,function (r) {
                result=r;
            })
            if(type=='applye'){
                if(result.code==2000){
                    laysuccess("新增成功");
                }else{
                    layerror("新增失败");
                }
            }
            $("#name").val("");
            $("#fid").val("");
            $("#sort").val('');
            $("#comment").val('');
            return result;
        }

    }


    //编写表单验证函数validform，在验证按钮注册按钮点击事件内调用验证函数对象
    function validform(){

        return $("#menuform").validate({
            rules : {
                name : "required",
                fid : "required",
                sort: {
                    required:true,
                    number:true
                },
                comment: {
                    maxlength: 100
                },
            },
            messages : {
                name : {
                    required: "名称不能为空"
                },
                fid : {
                    required: "IFD编码不能为空"
                },
                sort : {
                    required:"请输入有效的数字",
                    number: "请输入有效的数字",
                },
                comment : {
                    maxlength: "备注长度不可超过100"
                }
            }
        });

    }

</SCRIPT>
</html>